package com.gmss.crawler.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gmss.crawler.entity.AcademicianEntity;
import com.gmss.crawler.enums.AcademicianEnum;
import com.gmss.crawler.module.honor.domain.Honor;
import com.gmss.crawler.module.honor.service.IHonorService;
import com.gmss.crawler.module.person.domain.PersonInfo;
import com.gmss.crawler.module.resume.domain.Resume;
import com.gmss.crawler.module.resume.service.IResumeService;
import com.gmss.crawler.module.social.domain.Social;
import com.gmss.crawler.module.social.service.ISocialService;
import com.gmss.crawler.module.title.domain.PersonTitle;
import com.gmss.crawler.module.title.service.IPersonTitleService;
import com.gmss.crawler.utils.CommonUtils;
import com.gmss.crawler.utils.CrawlerCommonUtils;
import com.gmss.crawler.utils.DateUtils;
import com.gmss.crawler.utils.RegexUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;

/**
 * 百度百科爬取院士信息
 */
@Slf4j
@Service
public class BaiduBaiKeCrawlerService {

    @Resource
    private WikipediaCrawlerService wikipediaCrawlerService;
    @Resource
    private IPersonTitleService iPersonTitleService;
    @Resource
    private IHonorService iHonorService;
    @Resource
    private ISocialService iSocialService;
    @Resource
    private IResumeService iResumeService;

    // 院士信息-百度百科
    //    private static final String crawlerPath = "https://baike.baidu.com/item/常进院士?fr=aladdin";
    //    private static final String crawlerPath = "https://baike.baidu.com/item/陈彪?fr=aladdin";
    // 百度百科URL
    private static final String crawlerPath3 = "https://www.baidu.com/s?wd=";
    // 百度百科URL
    private static final String crawlerPath = "https://baike.baidu.com/item/";

    private static final String BAIKE_Path = "https://baike.baidu.com";
    // 百度百科根据人名搜索
    private static final String crawlerPath2 = "https://baike.baidu.com/search?word=$${1}&pn=0&rn=0&enc=utf8";

    // "社会任职"
    public static List<String> socialNameList = new ArrayList<String>() {{
        add("社会任职");
        add("社会职务");
        add("担任职务");
        add("主要经历");
        add("教育及工作经历");
        add("先后任职");
        add("学术兼职");
        add("工作经历");
        add("社会兼职");
        add("学术工作");
        add("学术任职");
        add("任免信息");
        add("主要学术任职");
        add("职务任免");
        add("主要社会兼职");
        add("主要任职");
        add("学习与工作履历");
    }};

    // "获得荣誉"
    public static List<String> honorNameList = new ArrayList<String>() {{
        add("获得荣誉");
        add("荣誉表彰");
        add("所获荣誉");
        add("荣誉奖励");
        add("学术荣誉");
        add("个人荣誉");
        add("奖励、荣誉和学术兼职");
        add("学术成就");
        add("获得称号");
        add("荣誉");
        add("荣誉及头衔");
        add("专业荣誉");
        add("人物荣誉");
        add("院士候选");
        add("参选院士");
        add("奖励荣誉");
        add("主要学术荣誉");
        add("主要荣誉");
        add("院士当选");
    }};

    // 科研奖项
    public static List<String> scientificNameList = new ArrayList<String>() {{
        add("获奖记录");
        add("获奖情况");
        add("获奖");
        add("奖项和荣誉");
        add("获奖与荣誉");
        add("获奖荣誉");
        add("所获奖项");
        add("所获奖励");
        add("获奖信息");
        add("科研成果奖");
        add("教学获奖");
        add("科研获奖");
        add("人物成就");
        add("科研成果奖励");
    }};

    // "人物生平"
    public static List<String> resumeNameList = new ArrayList<String>() {{
        add("生平");
        add("生平经历");
        add("人物生平");
        add("个人履历");
        add("人物简介");
        add("个人信息");
        add("人物履历");
        add("人物经历");
        add("人物简历");
        add("教育经历");
        add("教育背景");
        add("履历");
        add("个人经历");
        add("个人经历或学术经历");
        add("个人简历");
        add("学历");
        add("学习工作经历");
        add("求学经历");
    }};

    // "研究方向", "研究领域", "主要研究领域"
    public static List<String> researchNameList = new ArrayList<String>() {{
        add("研究方向");
        add("研究领域");
        add("主要研究领域");
    }};

    // 在社会任职中，过滤如下关键字
    public static List<String> noNameList = new ArrayList<String>() {{
//        add("科研项目");
        add("主要著作");
        add("论文专著");
        add("出版著作");
        add("著作章节：");
        add("著作章节:");
        add("著作章节");
        add("著作：");
        add("著作:");
        add("著作");
        add("译著：");
        add("译著:");
        add("译著");
        add("代表性论文");
        add("主要论著");
        add("研究方向");
//        add("研究成果");
    }};


    public static void main(String[] args) throws InterruptedException, IOException {
//        PersonInfo personInfo = new PersonInfo().builder().name("常进").build();
//        new BaiduBaiKeCrawlerService().getBaikeByPerson(personInfo, 0);
//        PersonInfo personInfo2 = new PersonInfo().builder().name("刘琳").build();
//        new BaiduBaiKeCrawlerService().getBaikeByPerson(personInfo2, 1);

//        Document doc = CrawlerCommonUtils.getDocumentByFile("C:\\Users\\user\\Desktop\\222.html");
//        System.out.println(doc.select(".album-list").toString());
//        System.out.println(doc.select(".scroller").select(".list").select("a").toString());
//        System.out.println(doc.select(".album-wrap").select("img").attr("src"));
//        String imgSrc2 = doc.select(".album-list").select("a").select("img").attr("src");
//        System.out.println(imgSrc2);
        System.out.println(StringUtils.join(noNameList, ","));


        if (StringUtils.containsAny("论文专著f5sd456f4s6著作章节af416dsa", StringUtils.join(noNameList, ","))) {
            System.out.println(1);
        } else {
            System.out.println(2);
        }


//        System.out.println(socialNameList.contains("社会任职"));
    }

    public void getBaikeByPerson(PersonInfo personInfo, JSONObject jsonObject, String filePath) throws InterruptedException, IOException {
        Document doc = null;
        String name = personInfo.getName();
        Integer type = jsonObject.getInteger("type");
        String electionYear = jsonObject.containsKey("electionYear") ? jsonObject.getString("electionYear") : "";
        if (type == 0) {
//            imgFilePath = imgFilePath;
            doc = getBaiDuDocument(personInfo, type);
        } else if (type == 1) {
//            imgFilePath = imgFilePath;
            doc = getBaiDuDocument(personInfo, type);
        } else if (type == 4) {
//            imgFilePath = imgFilePath;
            doc = getBaiDuDocument(personInfo, type);
        }  else if (type == 17) {
//            File file = new File(filePath);
//            if (!file.exists())
//                imgFilePath = imgFilePath + type + File.separator;
            doc = getBaiDuDocument(personInfo, type);
        }else {
            return;
        }

        if (null == doc) {
            log.error("Document is null - 百度百科，url条件：{}，人员id：{}，专业学科：{}，工作单位：{}，姓名：{}", personInfo.getName() + personInfo.getWorkCompany() + personInfo.getMajor(),
                    personInfo.getId(), personInfo.getMajor(), personInfo.getWorkCompany(), personInfo.getName());
            return;
        }

        // 解析百度百科html数据
        Map<String, String> map = getAcademicianData(doc, personInfo, type, filePath);
        // 把页面不同的字段进行统一
        handlerMap(map);

        if (map.containsKey("逝世日期") && StringUtils.isNotBlank(map.get("逝世日期")) && StringUtils.isBlank(personInfo.getDateOfDeath())) {
            // 逝世日期大于当选年，说明查询出的人员信息不正确
            if (judgeDateOfDeath(personInfo, type, map, "逝世日期")) return;
            personInfo.setDateOfDeath(map.get("逝世日期"));

        }

        if (map.containsKey("research") && StringUtils.isNotBlank(map.get("research")) && StringUtils.isBlank(personInfo.getResearchContents())) {
            personInfo.setResearchContents(map.get("research"));
        }
        if (map.containsKey("外文名") && StringUtils.isNotBlank(map.get("外文名")) && StringUtils.isBlank(personInfo.getForeignName())) {
            personInfo.setForeignName(map.get("外文名"));
        }
        if (map.containsKey("工作单位") && StringUtils.isNotBlank(map.get("工作单位"))) {
            personInfo.setWorkCompany(map.get("工作单位"));
        }

        if (map.containsKey("民族") && StringUtils.isNotBlank(map.get("民族")) && StringUtils.isBlank(personInfo.getNation())) {
            personInfo.setNation(map.get("民族"));
        } else if (StringUtils.isBlank(personInfo.getNation())) {
            if (map.containsKey("个人简介") && StringUtils.isNotBlank(map.get("个人简介"))) {
                String descData = map.get("个人简介");
                wikipediaCrawlerService.getNation(map, descData);
                if (map.containsKey("nation") && StringUtils.isNotBlank(map.get("nation"))) {
                    personInfo.setNation(map.get("nation"));
                }
            }
        }

        if (map.containsKey("出生地") && StringUtils.isNotBlank(map.get("出生地")) && StringUtils.isBlank(personInfo.getBirthplace())) {
            personInfo.setBirthplace(map.get("出生地"));
        }
        // 从人物经历中获取出生地
        if (map.containsKey("resumeData") && StringUtils.isNotBlank(map.get("resumeData"))
                && !map.containsKey("出生地") && StringUtils.isBlank(personInfo.getBirthplace())) {
            String data = map.get("resumeData");
            getBirthplaceByResume(personInfo, data);
        }

        // 从个人简介中获取出生地
        if (map.containsKey("个人简介") && StringUtils.isNotBlank(map.get("个人简介"))
                && !map.containsKey("出生地") && StringUtils.isBlank(personInfo.getBirthplace())) {
            String data = map.get("个人简介");
            getBirthplaceByResume(personInfo, data);
        }

        // 出生地没有数据，同时人物经历、个人简介中也没有数据，籍贯或原籍
        if (!map.containsKey("出生地") && StringUtils.isBlank(personInfo.getBirthplace())) {
            if (map.containsKey("籍贯") && StringUtils.isNotBlank(map.get("籍贯"))) {
                personInfo.setBirthplace(map.get("籍贯"));
            } else if (map.containsKey("原籍") && StringUtils.isNotBlank(map.get("原籍"))) {
                personInfo.setBirthplace(map.get("原籍"));
            }
        }

        if (map.containsKey("出生日期") && StringUtils.isNotBlank(map.get("出生日期")) && StringUtils.isBlank(personInfo.getBirthday())) {
            personInfo.setBirthday(map.get("出生日期"));
        }
        // 从人物经历中获取出生日期
        if (map.containsKey("resumeData") && StringUtils.isNotBlank(map.get("resumeData"))
                && !map.containsKey("出生日期") && StringUtils.isBlank(personInfo.getBirthday())) {
            String resume = map.get("resumeData");
            getBirthdayByResume(personInfo, resume);
        }

        // 从个人简介中获取出生日期
        if (map.containsKey("个人简介") && StringUtils.isNotBlank(map.get("个人简介"))
                && !map.containsKey("出生日期") && StringUtils.isBlank(personInfo.getBirthday())) {
            String data = map.get("个人简介");
            getBirthdayByResume(personInfo, data);
        }

        if (map.containsKey("毕业院校") && StringUtils.isNotBlank(map.get("毕业院校")) && StringUtils.isBlank(personInfo.getSchool())) {
            personInfo.setSchool(map.get("毕业院校"));
        }

        if (map.containsKey("性别") && StringUtils.isNotBlank(map.get("性别")) && StringUtils.isBlank(personInfo.getSex())) {
            personInfo.setSex(map.get("性别"));
        } else if (!map.containsKey("性别") && StringUtils.isBlank(personInfo.getSex()) &&
                map.containsKey("成就") && StringUtils.isNotBlank(map.get("成就"))
                && StringUtils.containsAny(map.get("成就"), "女科学家", "女作家", "女文学家")) {
            personInfo.setSex("女");
        }

        if (map.containsKey("成就") && StringUtils.isNotBlank(map.get("成就")) && StringUtils.isBlank(personInfo.getAchievement())) {
            String achievement = map.get("成就").replaceAll("收起", "");
            personInfo.setAchievement(achievement);
        }

        // 院士官网获取不到个人简介时使用
        if (map.containsKey("个人简介") && StringUtils.isNotBlank(map.get("个人简介")) && StringUtils.isBlank(personInfo.getDescribeData())) {
            personInfo.setDescribeData(map.get("个人简介"));
        }

        if (map.containsKey("职称") && StringUtils.isNotBlank(map.get("职称")) && StringUtils.isBlank(personInfo.getPersonTitle())) {
            personInfo.setPersonTitle(map.get("职称"));
        }
        if (map.containsKey("学位") && StringUtils.isNotBlank(map.get("学位")) && StringUtils.isBlank(personInfo.getAcademicDegree())) {
            String academicDegree = map.get("学位").replaceAll("\"", "");
            personInfo.setAcademicDegree(academicDegree);
        }

        // 非外籍或已故外籍
        if (personInfo.getAcademicianTitle() != null && !StringUtils.equalsAny(personInfo.getAcademicianTitle().toString(), "2", "3", "6", "7")) {
            if (map.containsKey("政党") && StringUtils.isNotBlank(map.get("政党")) && StringUtils.isBlank(personInfo.getPoliticalParty())) {
                personInfo.setPoliticalParty(map.get("政党"));
            } else {
                personInfo.setPoliticalParty("中国共产党");
            }

            if (map.containsKey("国籍") && StringUtils.isNotBlank(map.get("国籍")) && StringUtils.isBlank(personInfo.getNationality())) {
                personInfo.setNationality(map.get("国籍"));
            } else {
                personInfo.setNationality(map.get("中国"));
            }
        } else if (!map.containsKey("政党") && StringUtils.isBlank(personInfo.getPoliticalParty())) {
            if (map.containsKey("个人简介") && StringUtils.isNotBlank(map.get("个人简介"))) {
                wikipediaCrawlerService.getPoliticalParty(map, map.get("个人简介"));
            }
            if (!map.containsKey("politicalParty") && map.containsKey("resumeData") && StringUtils.isNotBlank(map.get("resumeData"))) {
                wikipediaCrawlerService.getPoliticalParty(map, map.get("resumeData"));
            }
            if (map.containsKey("politicalParty")) {
                personInfo.setPoliticalParty(map.get("politicalParty"));
            }
        }

        if (map.containsKey("国籍") && StringUtils.isNotBlank(map.get("国籍")) && StringUtils.isBlank(personInfo.getNationality())) {
            personInfo.setNationality(map.get("国籍"));
        }

        // 从人物经历中获取学位
        if (map.containsKey("resumeData") && StringUtils.isNotBlank(map.get("resumeData"))) {
            saveResumeData(personInfo, type, map);
        }

        // 科研成果、荣誉表彰
        if (map.containsKey("scientificResult") && StringUtils.isNotBlank(map.get("scientificResult"))) {
            saveHonorData(personInfo, type, map, "scientificResult", "honorsData");
        } else {
            // 获取子目录下的UL标签
            getScientificResultUL(doc, personInfo, type, map);
            if (map.containsKey("scientificResult") && StringUtils.isNotBlank(map.get("scientificResult"))) {
                saveHonorData(personInfo, type, map, "scientificResult", "honorsData");
            }
        }

        // 荣誉表彰
        if (map.containsKey("honorsData") && StringUtils.isNotBlank(map.get("honorsData"))) {
            saveHonorData(personInfo, type, map, "honorsData", "scientificResult");
        }

        //socialData
        if (map.containsKey("socialData") && StringUtils.isNotBlank(map.get("socialData"))) {
            saveSocialData(personInfo, type, map, "socialData");
        } else if (map.containsKey("社会任职") && StringUtils.isNotBlank(map.get("社会任职"))) {
            saveSocialData(personInfo, type, map, "社会任职");
        }
    }

    /**
     * 获取子目录下的UL标签，包含科研奖项的
     *
     * @param doc1
     * @param personInfo
     * @param type
     * @param map
     */
    private void getScientificResultUL(Document doc1, PersonInfo personInfo, Integer type, Map<String, String> map) {
        Elements liElements = doc1.select("div.main-content.J-content").select("ul li");
        for (int j = 0; j < liElements.size(); j++) {
            String text = liElements.get(j).text();
            if (StringUtils.isNotBlank(text) && scientificNameList.contains(text)) {
                String userName = map.containsKey("中文名") ? map.get("中文名") : "";
                String str = doc1.toString().substring(doc1.toString().lastIndexOf(text) + text.length(), doc1.toString().indexOf(liElements.get(j + 1).text()));
                List<Honor> list = new ArrayList();
                Document doc = CrawlerCommonUtils.getDocumentByString(str);
                Elements tbodyEle = doc.select("table tbody");
                Map<String, Integer> tbodyMap = new HashMap<>();
                for (int i = 0; i < tbodyEle.size(); i++) {
                    Elements trElements = tbodyEle.get(i).select("tr");
                    Elements thead = trElements.get(0).select("td");
                    if (thead.size() < 1) {
                        thead = trElements.get(0).select("th");
                    }
                    tbodyMap = CasCrawlerService.getStringIntegerMap(thead);
                    setSubHonorMap(tbodyMap, trElements, list, userName, 0);
                }
                if (CollectionUtils.isNotEmpty(list)) {
                    for (Honor honor : list) {
                        honor.setPersonId(personInfo.getId());
                    }
                }
                if (!map.containsKey("scientificResult")) {
                    map.put("scientificResult", JSON.toJSONString(list));
                } else if (map.containsKey("scientificResult") && StringUtils.isNotBlank(map.get("scientificResult"))) {
                    List<Honor> list2 = JSON.parseArray(map.get("scientificResult"), Honor.class);
                    list.addAll(list2);
                    map.put("scientificResult", JSON.toJSONString(list));
                }
            }
//            System.out.println(liElements.get(i).text());

        }

    }

    /**
     * 逝世日期大于当选年，说明查询出的人员信息不正确
     *
     * @param personInfo 人员信息
     * @param type       0：院士信息，1：长江学者，2：杰出青年，3：百人计划
     * @param map        保存数据的map
     * @param str        查询map的key名称
     * @return
     */
    public boolean judgeDateOfDeath(PersonInfo personInfo, Integer type, Map<String, String> map, String str) {
        String electionYear = "";
        if (type == 1) {
            List<Integer> list2 = new ArrayList<>();
            list2.add(AcademicianEnum.CHANGJIANG_SCHOLAR_SPECIAL.getCode());
            list2.add(AcademicianEnum.CHANGJIANG_SCHOLAR_LECTURE.getCode());
            list2.add(AcademicianEnum.CHANGJIANG_SCHOLAR_YOUTH.getCode());
            Long psersonId = personInfo.getId();
            LambdaQueryWrapper<PersonTitle> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(PersonTitle::getPersonId, psersonId);
            lambdaQueryWrapper.in(PersonTitle::getAcademicianTitle, list2);
            List<PersonTitle> personTitleList = iPersonTitleService.list(lambdaQueryWrapper);
            electionYear = personTitleList.get(0).getElectionYear();
        }
        try {
            if (StringUtils.isNotBlank(electionYear) && StringUtils.contains(electionYear, "年")) {

                electionYear = electionYear.substring(electionYear.indexOf("年") - 4, electionYear.indexOf("年"));
                Date electionYearDate = DateUtils.stringToDateFormat(electionYear, "yyyy");
                String dateOfDeath = map.get(str);
                if (StringUtils.contains(dateOfDeath, "年")) {
                    dateOfDeath = dateOfDeath.substring(dateOfDeath.indexOf("年") - 4, dateOfDeath.indexOf("年"));
                } else if (StringUtils.contains(dateOfDeath, "\\.")) {
                    dateOfDeath = dateOfDeath.substring(dateOfDeath.indexOf("\\.") - 4, dateOfDeath.indexOf("\\."));
                } else if (StringUtils.contains(dateOfDeath, "-")) {
                    dateOfDeath = dateOfDeath.substring(dateOfDeath.indexOf("-") - 4, dateOfDeath.indexOf("-"));
                }
                Date dateOfDeathDate = DateUtils.stringToDateFormat(dateOfDeath, "yyyy");
                if (dateOfDeathDate.getTime() < electionYearDate.getTime()) {
                    return true;
                }
            }
        } catch (Exception e) {
        }
        return false;
    }

    /**
     * 科研奖项/荣誉数据入库
     *
     * @param personInfo 人员信息
     * @param type       0：院士信息，1：长江学者，2：杰出青年，3：百人计划
     * @param map        保存数据的map
     * @param saveResult 入库数据
     * @param honorsData 用于合并数据，把honorsData合并到saveResult
     */
    public void saveHonorData(PersonInfo personInfo, Integer type, Map<String, String> map, String saveResult, String honorsData) {
        List<Honor> list = JSON.parseArray(map.get(saveResult), Honor.class);
        if (map.containsKey(honorsData) && StringUtils.isNotBlank(map.get(honorsData))) {
            List<Honor> honorsDataList = JSON.parseArray(map.get(honorsData), Honor.class);
            list.addAll(honorsDataList);
        }
        try {
            iHonorService.saveHonorByPersonId(personInfo, list);
//            iHonorService.saveHonor(personInfo, list);
        } catch (Exception e) {
            log.error("科研奖项/荣誉  姓名：{}，工作单位：{}，id：{}，type：{}，saveScientificData-Exception：{}", personInfo.getName(), personInfo.getWorkCompany(), personInfo.getId(), type, e);
        }
    }

    /**
     * 社会任职数据入库
     *
     * @param personInfo 人员信息
     * @param type       0：院士信息，1：长江学者，2：杰出青年，3：百人计划
     * @param map        保存数据的map
     * @param socialData 查询map的key名称
     */
    public void saveSocialData(PersonInfo personInfo, Integer type, Map<String, String> map, String socialData) {
        try {
            List<Social> list = JSON.parseArray(map.get(socialData), Social.class);
            iSocialService.saveSocialByPersonId(personInfo, list);
//            iSocialService.saveSocial(personInfo, list);
        } catch (Exception e) {
            //姓名：{}，工作单位：{}，id：{}，type：{}", name, personInfo.getWorkCompany(), personInfo.getId(), type
            log.error("BaiduBaiKeCrawlerService saveSocial 社会任职 姓名：{}，工作单位：{}，id：{}，type：{}，Exception：{}", personInfo.getName(), personInfo.getWorkCompany(), personInfo.getId(), type, e);
        }
    }

    /**
     * 人物经历数据入库
     *
     * @param personInfo 人员信息
     * @param type       0：院士信息，1：长江学者，2：杰出青年，3：百人计划
     * @param map        查询map的key名称
     */
    public void saveResumeData(PersonInfo personInfo, Integer type, Map<String, String> map) {
        String name = personInfo.getName();
        // 学位
        if (StringUtils.isBlank(personInfo.getAcademicDegree())) {
            setProperty(map, map.get("resumeData"), "学位");
            personInfo.setAcademicDegree(map.get("学位"));
        }

        String resume = map.get("resumeData");
        List<String> resumeArray = null;
        List<Resume> resumeList = new ArrayList<>();
        try {
            resumeArray = JSON.parseArray(resume, String.class);
        } catch (Exception e) {
            Document resumeDoc = CrawlerCommonUtils.getDocumentByString(resume);
            Elements resumeDivs = resumeDoc.select("div");
            for (Element resumeDiv : resumeDivs) {
                String[] resumes = resumeDiv.text().replaceAll("，", ",").split(",");
                if (resumes.length > 2) {
                    Resume resume1 = new Resume().builder().personId(personInfo.getId()).build();
                    StringBuilder sb = new StringBuilder();
                    if (StringUtils.isNotBlank(resumes[0]) && StringUtils.contains(resumes[0], "年") && resumes[0].length() <= 10) {
                        resume1.setResumeDate(resumes[0]);
                    }

                    for (int i = 1; i < resumes.length; i++) {
                        sb.append(resumes[i]).append(",");
                    }
                    resume1.setResume(sb.substring(0, sb.toString().lastIndexOf(",")));
                    resumeList.add(resume1);
                } else if (resumes.length == 1 && StringUtils.isNotBlank(resumes[0]) && !StringUtils.containsAny(resumes[0], "：", ":", name)) {
                    if (StringUtils.isNotBlank(resumes[0]) && !StringUtils.containsAny(resumes[0], "学历", "经历")) {
                        String resumeStr = RegexUtils.replaceData(resumes[0], RegexUtils.ALL_ZHONG_REGEX, "");
                        resumeStr = resumeStr.replaceAll("学习经历", "")
                                .replaceAll("主要学历", "").replaceAll("工作经历", "")
                                .replaceAll("：", "")
                                .replaceAll(name + "教授", "")
                                .replaceAll("：", ":").replaceAll(":", "")
                                .replaceAll("。", "")
                                .replaceAll("其中", "");

                        if (StringUtils.isNotBlank(resumeStr)) {
                            Resume resume1 = new Resume().builder().personId(personInfo.getId()).resume(resumeStr).build();
                            resumeList.add(resume1);
                        }
                    }
                }
            }
        }
        if (CollectionUtils.isEmpty(resumeList)) {
            for (String str : resumeArray) {
                if (StringUtils.isBlank(personInfo.getSchool())) {
                    String school = RegexUtils.getTextContent(str, RegexUtils.SCHOOL_REGEX);
                    if (StringUtils.isNotBlank(school))
                        school = school + "大学";

                    if (StringUtils.isBlank(school))
                        school = RegexUtils.getTextContent(str, RegexUtils.SCHOOL_REGEX2);
                    if (StringUtils.isNotBlank(school))
                        school = school + "学校";
                    if (StringUtils.isBlank(school))
                        school = RegexUtils.getTextContent(str, RegexUtils.SCHOOL_REGEX3);

                    if (StringUtils.isNotBlank(school))
                        school = school + "学院";

                    if (StringUtils.isNotBlank(school))
                        personInfo.setSchool(school);
                }
                Resume re = new Resume();
                str = RegexUtils.replaceData(str, RegexUtils.ALL_ZHONG_REGEX, "");
                str = str.replaceAll("，", ",");
                if (str.indexOf(",") > 0) {
                    String startResume = str.substring(0, str.indexOf(","));
                    String endResume = str.substring(str.indexOf(",") + 1, str.length());

                    String dd = RegexUtils.getTextContent(startResume, RegexUtils.ALL_KUA_REGEX_TWO);
                    if (dd.contains("张"))
                        startResume = RegexUtils.replaceData(startResume, RegexUtils.ALL_KUA_REGEX, "");
                    startResume = RegexUtils.replaceData(startResume, name, "");
                    endResume = RegexUtils.replaceData(endResume, name, "");
                    if (StringUtils.isNotBlank(startResume)) {
                        try {
                            re.setResumeDate(DateUtils.handleDate(startResume));
                            re.setResume(endResume);
                        } catch (Exception e) {
                            re.setResume(startResume + "," + endResume);
                        }
                    } else {
                        re.setResume(str);
                    }
                } else {
                    String[] strs = str.split("　");
                    if (strs.length > 1) {
                        try {
                            re.setResumeDate(DateUtils.handleDate(strs[0]));
                            re.setResume(strs[1]);
                        } catch (Exception e) {
                            re.setResume(strs[0] + "," + strs[1]);
                        }
                    } else if (StringUtils.isNotBlank(strs[0])) {
                        String dd = RegexUtils.getTextContent(strs[0], RegexUtils.ALL_KUA_REGEX_TWO);
                        if (dd.contains("张"))
                            strs[0] = RegexUtils.replaceData(strs[0], RegexUtils.ALL_KUA_REGEX, "");
                        strs[0] = RegexUtils.replaceData(strs[0], name, "");
                        if (StringUtils.isNotBlank(strs[0]))
                            re.setResume(strs[0]);
                    }
                }

                if (re != null && StringUtils.isNotBlank(re.getResume()))
                    resumeList.add(re);
            }
        }
        try {
            iResumeService.saveResumeByPersonId(personInfo, resumeList);
//            iResumeService.saveResume(personInfo, resumeList);
        } catch (Exception e) {
            log.error("BaiduBaiKeCrawlerService saveResume 人物经历 姓名：{}，工作单位：{}，id：{}，type：{}，Exception：{}", name, personInfo.getWorkCompany(), personInfo.getId(), type, e);
        }
    }

    /**
     * 从人物经历、个人简介中获取出生地
     *
     * @param personInfo
     * @param data
     */
    public void getBirthplaceByResume(PersonInfo personInfo, String data) {
        if (StringUtils.isBlank(data))
            return;
        String birthplace = RegexUtils.getTextContent(data, RegexUtils.BIRTHPLACE);
        if (StringUtils.isBlank(birthplace))
            birthplace = RegexUtils.getTextContent(data, RegexUtils.BIRTHPLACE_TWO);

        if (StringUtils.isNotBlank(birthplace) && StringUtils.isBlank(personInfo.getBirthplace()) && !birthplace.contains("年")) {
            try {
                // 有可能会获取到出生日期，把出生日期转换成Date，转换成功说明不是出生地，而是出生日期。
                String birthday = DateUtils.handleDate(birthplace);
                personInfo.setBirthday(birthday);
            } catch (Exception e) {
                personInfo.setBirthplace(birthplace);
            }
        }
    }

    /**
     * 从人物经历、个人简介中获取出生日期
     *
     * @param personInfo
     * @param resumeData
     */
    public void getBirthdayByResume(PersonInfo personInfo, String resumeData) {
        if (StringUtils.isBlank(resumeData))
            return;
        String birthday = RegexUtils.getTextContent(resumeData, RegexUtils.BIRTHDAY);
        if (StringUtils.isBlank(birthday))
            birthday = RegexUtils.getTextContent(resumeData, RegexUtils.BIRTHDAY_TWO);
        if (StringUtils.isBlank(birthday))
            birthday = RegexUtils.getTextContent(resumeData, RegexUtils.BIRTHDAY_THREE);
        if (StringUtils.isBlank(birthday))
            birthday = RegexUtils.getTextContent(resumeData, RegexUtils.BIRTHDAY_FOUR);
        String birthdayStr = CommonUtils.getBirthdayByString(birthday);
        if (StringUtils.isNotBlank(birthdayStr))
            personInfo.setBirthday(birthdayStr);
    }

    /**
     * 所在单位
     *
     * @param personInfo
     * @param data
     */
    private void work(PersonInfo personInfo, String data) {
        getWorkComapny(personInfo, data, RegexUtils.WORK_REGEX);
//        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
//            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX6);
//        }
//        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
//            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX7);
//        }
//        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
//            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX8);
//        }
        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX2);
        }
        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX3);
        }
        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX4);
        }
//        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
//            getWorkComapny(personInfo, personInfo.getDescribeData(), RegexUtils.WORK_REGEX5);
//        }
    }

    public void getWorkComapny(PersonInfo personInfo, String data, String regex) {
        // 所在单位
        if (StringUtils.isBlank(personInfo.getWorkCompany())) {
//            String workCompany = RegexUtils.getTextContent(personInfo.getDescribeData(), RegexUtils.WORK_REGEX);
            String workCompany = RegexUtils.getTextContent(data, regex);
            if (StringUtils.isNotBlank(workCompany)) {
                workCompany = workCompany.replaceAll("（", "(").replaceAll("）", ")");
                // 去除()
                workCompany = RegexUtils.replaceData(workCompany, RegexUtils.ALL_KUA_REGEX, "");
                personInfo.setWorkCompany(workCompany);
            }
        }
    }

    /**
     * 解析百度百科html数据
     *
     * @param doc
     * @return
     */
    private Map<String, String> getAcademicianData(Document doc, PersonInfo personInfo, Integer type, String filePath) throws InterruptedException {
        // 保存院士数据的map
        Map<String, String> map = new HashMap<>();
        // 先判断有没有院士个人图像，院士网站没有个人图像时，重新获取个人图像
        boolean imgCrawler = false;
        String fileName = personInfo.getId() + ".jpg";
        File file = new File(filePath + fileName);
        if (StringUtils.isBlank(personInfo.getImgName()) || !file.exists()) {
            imgCrawler = true;
        }
        String lemmaSummaryDivs = "";
        Elements contentElements = doc.select("div.main-content.J-content");
        if (null != contentElements && contentElements.size() == 0) {
            try {
                Thread.sleep(CommonUtils.randomRange(2000, 5000));
            } catch (InterruptedException e) {
            }
            Elements contentElements2 = doc.select(".main-content.J-content");
            if (null != contentElements2 && contentElements2.size() == 0) {
                log.error("main-content.J-content不存在，姓名：{}，工作单位：{}，id：{}", personInfo.getName(), personInfo.getWorkCompany(), personInfo.getId());
                return map;
            }
            try {
                lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").get(0).text();
            } catch (Exception e) {
                lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").text();
            }
        }

        if (StringUtils.isBlank(lemmaSummaryDivs)) {
            try {
                lemmaSummaryDivs = contentElements.get(0).select(".lemma-summary").select("div").get(0).text();
            } catch (Exception e) {
                lemmaSummaryDivs = contentElements.get(0).select(".lemma-summary").select("div").text();
            }
        }
        if (type!=17 && StringUtils.contains(lemmaSummaryDivs, personInfo.getName()) && !StringUtils.contains(doc.toString(), personInfo.getName() + "的概述图")) {
            return map;
        }
        if (imgCrawler) {
            String imgSrc = doc.select("div.summary-pic").select("a").select("img").attr("src");
            fileName = personInfo.getId() + ".jpg";
            if (StringUtils.isNotBlank(imgSrc)) {
                file = new File(filePath + fileName);
                // 判断图片是否存在，如果不存在下载
                if (!file.exists() || StringUtils.isBlank(personInfo.getImgName())) {
                    CrawlerCommonUtils.getPersonalImgSave(imgSrc, filePath, fileName);
                    personInfo.setImgName(fileName);
                }
            }
        }

        lemmaSummaryDivs = RegexUtils.replaceData(lemmaSummaryDivs, RegexUtils.ALL_ZHONG_REGEX, "").replaceAll("，", ",");
        map.put("个人简介", lemmaSummaryDivs);

        // 获取学位信息
        if (StringUtils.contains(lemmaSummaryDivs, "国务院学位委员会")) {
            map.put("学位", "博士学位");
        }
        if (map.containsKey("学位") && StringUtils.isNotBlank(map.get("学位"))) {
            setProperty(map, lemmaSummaryDivs, "学位");
        }

        // 百度百科人物基本信息
        Elements dlElements = contentElements.get(0).select(".basic-info.J-basic-info.cmn-clearfix").select("dl");

        for (Element element : dlElements) {
            Elements dtElements = element.select("dt");
            Elements ddElements = element.select("dd");
            for (int i = 0; i < dtElements.size(); i++) {
                String title = CommonUtils.replaceBlank(dtElements.get(i).text()).replaceAll("&nbsp;", "").replaceAll(" ", "");
                String titleValue = ddElements.get(i).text();
                titleValue = RegexUtils.replaceData(titleValue, RegexUtils.ALL_ZHONG_REGEX, "");
                map.put(title, titleValue);
            }
        }

        // 百度百科人物目录
        Map<String, Object> menuMap = new HashMap<>();
        List<String> upperLevelList = new ArrayList<>();
        Elements liElements = doc.select(".lemma-catalog").select("div").select("ol").select("li");
        String upperLevel = "";
        for (Element element : liElements) {
            String menuHref = element.select("a").attr("href").replaceAll("#", "");
            String menuText = element.select("a").text();
            if (StringUtils.contains(menuHref, "_")) {
                upperLevel = menuHref.split("_")[0];
                String thisLevel = menuHref.split("_")[1];
                if (StringUtils.equals(thisLevel, "1")) {
                    String levelValue = menuMap.get(upperLevel).toString();
                    levelValue = levelValue.replaceAll("&", "&amp;");
                    upperLevelList.add(levelValue);
                }
                upperLevelList.add(menuText);
            } else {
                upperLevel = "";
            }
            if (StringUtils.isNotBlank(upperLevel)) {
                menuMap.put(upperLevel, upperLevelList);
            } else {
                upperLevelList = new ArrayList<>();
                menuMap.put(menuHref, menuText);
            }
        }

        String name = personInfo.getName();
        // 所有menuMap的value=List的下标0的值，都是一级目录
        Map<String, String> subMap = new HashMap<>();
        menuMap.forEach((key, value) -> {
            if (!ObjectUtils.isEmpty(value) && value instanceof String) {
                // 处理一级目录
                handleMenu(map, contentElements, menuMap, key, value, name);
            } else if (!ObjectUtils.isEmpty(value) && value instanceof ArrayList) {
                List<String> subMenuList = (List) value;
                // 处理一级目录
                handleMenu(map, contentElements, menuMap, key, subMenuList.get(0), name);

                for (int i = 1; i < subMenuList.size(); i++) {
                    handleSubMenu(map, contentElements, menuMap, i, subMenuList, key);
                    handleSubStr(map, subMap);
                }
            }
        });


        // 从个人简介中获取属性
        getLemmaSummaryDivsProperty(map, lemmaSummaryDivs);
        getLemmaSummaryDivsProperty(map, map.get("人物经历"));
        map.putAll(subMap);
        return map;
    }

    private void handleSubStr(Map<String, String> map, Map<String, String> subMap) {
        AtomicReference<String> data = new AtomicReference<>("");
        map.forEach((key, value) -> {
            if (StringUtils.equalsAny(key, "科研成就")) {
                Document doc = CrawlerCommonUtils.getDocumentByString(value);
                String text = doc.select("div").text();
                map.put(key, text);
            }
            if (StringUtils.equalsAny(key, "项目承担&amp;成果奖励", "科研成果奖励", "科研获奖", "科研奖励")) {
                String userName = map.containsKey("中文名") ? map.get("中文名") : "";
                // table样式
                List<Honor> list = new ArrayList();
                Document doc = CrawlerCommonUtils.getDocumentByString(value);
                Elements tbodyEle = doc.select("table tbody");
                Map<String, Integer> tbodyMap = new HashMap<>();
                for (int i = 0; i < tbodyEle.size(); i++) {
                    Elements trElements = tbodyEle.get(i).select("tr");
                    Elements thead = trElements.get(0).select("td");
                    if (thead.size() < 1) {
                        thead = trElements.get(0).select("th");
                    }
                    tbodyMap = CasCrawlerService.getStringIntegerMap(thead);
                    setSubHonorMap(tbodyMap, trElements, list, userName, 0);
                }
                if (CollectionUtils.isEmpty(list)) {
                    Elements divElements = doc.select("div");
                    for (int i = 0; i < divElements.size(); i++) {
                        Element divElem = divElements.get(i);
                        String devText = divElem.text().replaceAll(userName, "");
                        devText = RegexUtils.replaceData(devText, RegexUtils.ALL_ZHONG_REGEX, "");
                        if (StringUtils.isNotBlank(devText)) {
                            Honor honor = new Honor().builder().type(0).name(userName).build();
                            if (devText.indexOf("。") > 0) {
                                String[] divs = devText.split("。");
                                for (int j = 0; j < divs.length; j++) {
                                    honor = new Honor().builder().type(0).name(userName).build();
                                    String honorsData = divs[j].replaceAll("（", "(").replaceAll("）", ")");
                                    getPrizeLevel(honor, honorsData);
                                    getAwardLevel(honor, honorsData);
                                    honor.setPrizeName(honorsData);
                                    list.add(honor);
                                }
                            } else {
                                honor.setPrizeName(devText);
                                list.add(honor);
                            }
                        }
                    }
                }


                // 科研成果
                subMap.put("scientificResult", JSON.toJSONString(list));
//                data.set(JSON.toJSONString(list));


            } else if (StringUtils.equalsAny(key, "承担项目&amp;成果奖励", "成果目录", "科研成果", "科研成果奖励&amp;专利")) {
                // 科研成果、科研成果奖励div样式
                Document doc = CrawlerCommonUtils.getDocumentByString(value);
                Elements div = doc.select("div");
                List<Honor> list = new ArrayList();
                for (Element d : div) {
//                    Honor honorEntity = new Honor().builder().name(map.get("中文名")).type(0).build();
                    Honor honorEntity = new Honor().builder().type(0).build();
                    if (map.containsKey("中文名") && StringUtils.isNotBlank(map.get("中文名"))) {
                        honorEntity.setName(map.get("中文名"));
                    }
                    String honorText = d.text();
                    honorText = RegexUtils.replaceData(honorText, RegexUtils.ALL_ZHONG_REGEX, "");
                    honorText = honorText.replaceAll("，", ",").replaceAll("截至", "");
                    if (honorText.indexOf(",") > 0) {
                        String startHonor = honorText.substring(0, honorText.indexOf(","));
                        String endHonor = honorText.substring(honorText.indexOf(",") + 1, honorText.length());
                        try {
                            honorEntity.setHonorDate(DateUtils.handleDate(startHonor));
                            setHonorData(honorEntity, honorText, endHonor);
                        } catch (Exception e) {
                            setHonorData(honorEntity, honorText, honorText);
                        }
                        setHonorData(honorEntity, honorText, endHonor);
                    } else {
                        setHonorData(honorEntity, honorText, honorText);
                    }

                    list.add(honorEntity);
                }
                subMap.put("scientificResult", JSON.toJSONString(list));
            }
            if (StringUtils.equalsAny(key, "荣誉表彰")) {
                String userName = map.containsKey("中文名") ? map.get("中文名") : "";
                List<Honor> list = new ArrayList();
                if (StringUtils.isNotBlank(value)) {
                    Document doc = CrawlerCommonUtils.getDocumentByString(value);
                    Elements elements = doc.select("table");
                    Map<String, AcademicianEntity> academicianEntityMap = new HashMap<>();
                    for (int i = 0; i < elements.size(); i++) {
                        Elements thead = elements.get(i).select("thead tr th");
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("thead tr td");
                        }
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("tbody tr th");
                        }
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("tbody tr td");
                        }
                        Map<String, Integer> tbodyMap = CasCrawlerService.getStringIntegerMap(thead);
                        Elements trElements = elements.get(i).select("tbody").select("tr");
                        getTableSaveHonor(tbodyMap, trElements, list, userName, 1);
                    }
                    if (CollectionUtils.isNotEmpty(list))
                        subMap.put("honorsData", JSON.toJSONString(list));

                    if (MapUtils.isNotEmpty(subMap) && !subMap.containsKey("honorsData")) {
                        String[] honors = value.split("。");
                        for (String hStr : honors) {
                            Honor honorEntity = new Honor().builder().type(1).build();
                            if (map.containsKey("中文名") && StringUtils.isNotBlank(map.get("中文名"))) {
                                honorEntity.setName(map.get("中文名"));
                            }
                            hStr = hStr.replaceAll("，", ",");
                            if (hStr.indexOf(",") < 0) {
                                continue;
                            }
                            String dateStr = hStr.substring(0, hStr.indexOf(","));
                            String textStr = hStr.substring(hStr.indexOf(",") + 1, hStr.length());
                            try {
                                honorEntity.setHonorDate(DateUtils.handleDate(dateStr));
                                setHonorData(honorEntity, hStr, textStr);
                            } catch (Exception e) {
                                setHonorData(honorEntity, hStr, hStr);
                            }
                            list.add(honorEntity);
                        }
                    }
                    if (MapUtils.isNotEmpty(subMap) && !subMap.containsKey("honorsData")) {
                        subMap.put("honorsData", JSON.toJSONString(list));
                    }
                }
            }
        });
    }

    private void getTableSaveHonor(Map<String, Integer> tbodyMap, Elements trElements, List<Honor> list, String userName, Integer type) {
        String dateTmp = "";
        for (int j = 1; j < trElements.size(); j++) {
            Honor honorEntity = new Honor().builder().type(type).build();
            if (StringUtils.isNotBlank(userName)) {
                honorEntity.setName(userName);
            }
            //姓名
            int finalJ = j;
            String data = "";
            for (Map.Entry<String, Integer> entry : tbodyMap.entrySet()) {
                String key = entry.getKey();
                Integer value = entry.getValue();
                Elements tdElements = trElements.get(finalJ).select("td");
                if (!(tdElements.size() > 0) || tdElements.size() == 1) {
                    continue;
                }

                if (StringUtils.equalsAny(key, "获奖年份", "时间", "获奖时间", "年份")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    if (StringUtils.isNotBlank(data)) {
                        dateTmp = data;
                    }
                    try {
                        honorEntity.setHonorDate(DateUtils.handleDate(dateTmp));
                    } catch (Exception e) {
                        honorEntity.setHonorDate(data);
                    }
                }
                if (StringUtils.equalsAny(key, "所获荣誉", "获奖项目", "获奖项目名称", "项目名称", "成果名称", "奖项/荣誉", "荣誉称号", "荣誉表彰", "荣誉", "荣誉/表彰")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    setHonorData(honorEntity, data, data);

                }
                if (StringUtils.equalsAny(key, "奖励名称", "获奖等级", "奖项", "奖项名称")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    setHonorData(honorEntity, data, data);
                }
                if (StringUtils.equalsAny(key, "颁发单位", "授予单位", "授予方")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    honorEntity.setIssueCompany(data);
                }

            }
            list.add(honorEntity);
        }
    }

    /**
     * 科技成果/荣誉表彰
     *
     * @param honorEntity 科技成果/荣誉表彰bean
     * @param honorName   完整的数据
     * @param honorsData  完整数据中，分离出来的详情数据，如果没有分离数据，传完整的数据
     */
    public void setHonorData(Honor honorEntity, String honorName, String honorsData) {
        if (StringUtils.isNotBlank(honorName)) {
            honorsData = honorsData.replaceAll("（", "(").replaceAll("）", ")");
            getPrizeLevel(honorEntity, honorsData);
            getAwardLevel(honorEntity, honorsData);
            getCompletePerson(honorEntity, honorsData);
            if (StringUtils.isNotBlank(honorsData)) {
                honorEntity.setPrizeName(honorsData);
            } else {
                honorEntity.setPrizeName(honorName);
            }
        }
    }


    public void setSubMap(Map<String, Integer> tbodyMap, Elements trElements, List<Social> list, String userName) {
//        String dateTmp = "";
        for (int j = 1; j < trElements.size(); j++) {
            //姓名
            int finalJ = j;
            String data = "";
            Social social = new Social().builder().build();
            if (StringUtils.isNotBlank(userName)) {
                social.setName(userName);
            }

            for (Map.Entry<String, Integer> entry : tbodyMap.entrySet()) {
                String key = entry.getKey();
                Integer value = entry.getValue();
                Elements tdElements = trElements.get(finalJ).select("td");
                if (!(tdElements.size() > 0) || tdElements.size() == 1) {
                    continue;
                }

                if (StringUtils.equalsAny(key, "任职时间", "时间")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
//                    if (StringUtils.isNotBlank(data)) {
//                        dateTmp = data;
//                    }
//                    try {
                    social.setTenure(data);
//                    } catch (Exception e) {
//                        social.setTenure(data);
//                    }
                }
                if (StringUtils.equalsAny(key, "职务", "担任职务", "任职单位")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    social.setDuties(data);
                }
            }
            if (StringUtils.isNotBlank(social.getDuties())) {
                list.add(social);
            }
        }
    }


    public void setSubHonorMap(Map<String, Integer> tbodyMap, Elements trElements, List<Honor> list, String userName, Integer type) {
        String dateTmp = "";
        for (int j = 1; j < trElements.size(); j++) {
            //姓名
            int finalJ = j;
            String data = "";
            Honor honor = new Honor().builder().type(type).build();
            if (StringUtils.isNotBlank(userName)) {
                honor.setName(userName);
            }
            for (Map.Entry<String, Integer> entry : tbodyMap.entrySet()) {
                String key = entry.getKey();
                Integer value = entry.getValue();
                Elements tdElements = trElements.get(finalJ).select("td");
                if (!(tdElements.size() > 0) || tdElements.size() == 1) {
                    continue;
                }

                if (StringUtils.equalsAny(key, "获奖年份", "时间", "获奖时间")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    if (StringUtils.isNotBlank(data)) {
                        dateTmp = data;
                    }
                    try {
                        honor.setHonorDate(DateUtils.handleDate(dateTmp));
                    } catch (Exception e) {
                        honor.setHonorDate(data);
                    }
                }
                if (StringUtils.equalsAny(key, "获奖项目", "获奖项目名称", "项目名称", "成果名称", "奖励名称", "获奖等级", "奖项", "奖项名称", "所获奖励及等级")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    setHonorData(honor, data, data);
//                    honor.setPrizeName(data);
                }
                if (StringUtils.equals(key, "作者排名")) {
                    data = trElements.get(finalJ).select("td").get(value).text().replaceAll(" ", "");
                    data = RegexUtils.replaceData(data, RegexUtils.ALL_ZHONG_REGEX, "");
                    honor.setCompletePerson(data);
                }
            }
            list.add(honor);
        }
    }

    /**
     * 目录下的子目录处理
     *
     * @param map             保存院士数据的map
     * @param contentElements html内容
     * @param menuMap         根目录
     * @param i               上级循环list的下标
     * @param subMenuList     子目录list
     */
    private void handleSubMenu(Map<String, String> map, Elements contentElements, Map<String, Object> menuMap, int i, List<String> subMenuList, String key) {
        if (StringUtils.equals(subMenuList.get(i), "科研成就")) {
            handleSubScreenData(map, contentElements, menuMap, i, subMenuList, key);
        }
        if (StringUtils.equals(subMenuList.get(i), "人才培养")) {
//            handleSubScreenData(map, contentElements, menuMap, i, subMenuList);
        }
//        if (StringUtils.equalsAny(subMenuList.get(i), "荣誉表彰")) {
//            handleSubScreenData(map, contentElements, menuMap, i, subMenuList, key);
//        }
        if (scientificNameList.contains(subMenuList.get(i)) || honorNameList.contains(subMenuList.get(i))) {
            handleSubScreenData(map, contentElements, menuMap, i, subMenuList, key);
        }
    }

    /**
     * 子目录数据处理
     *
     * @param map
     * @param contentElements
     * @param menuMap
     * @param i
     * @param subMenuList
     * @param key
     */
    private void handleSubScreenData(Map<String, String> map, Elements contentElements, Map<String, Object> menuMap, int i, List<String> subMenuList, String key) {
        String content = contentElements.toString().substring(contentElements.toString().indexOf(subMenuList.get(i)) + subMenuList.get(i).length(), contentElements.toString().length());
        String endFlag = content.substring(0, 10);
        // 递归截取多个value值情况，只保留当前value最后一次出现到menuMap当前value的下一个value之前内容
        subScreenData(content, endFlag, i, subMenuList, map, menuMap, key);
    }

    /**
     * 子目录解析
     *
     * @param content
     * @param endFlag
     * @param index
     * @param subMenuList
     * @param map
     * @param menuMap
     * @param key
     */
    private void subScreenData(String content, String endFlag, int index, List<String> subMenuList, Map<String, String> map, Map<String, Object> menuMap, String key) {
        if (StringUtils.contains(endFlag, "</h3>")) {

            Object obj = "";
            String objStr = "";
            if (index == subMenuList.size() - 1) {
                int tempKey = Integer.parseInt(key) + 1;
                obj = menuMap.get(String.valueOf(tempKey));
            } else {
                int tempKey = index + 1;
                obj = subMenuList.get(tempKey);
            }
            if (obj instanceof String) {
                objStr = obj.toString();
            } else if (obj instanceof List) {
                List list = (List) obj;
                objStr = list.get(0).toString();
            }

            if (StringUtils.isNotBlank(objStr)) {
                String userName = map.containsKey("中文名") ? map.get("中文名") : "";
                String subMenuContent = content.substring(0, content.lastIndexOf(objStr));
                Document subDoc = CrawlerCommonUtils.getDocumentByString(subMenuContent);
                if (StringUtils.containsAny(subDoc.toString(), StringUtils.join(noNameList, ","))) {
                    for (int i = 0; i < noNameList.size(); i++) {
                        if (subDoc.toString().indexOf(noNameList.get(i)) > 0) {
                            String subStr = subDoc.toString().substring(0, subDoc.toString().indexOf(noNameList.get(i)));
                            subDoc = CrawlerCommonUtils.getDocumentByString(subStr);
                        }
                    }
                }


                Elements subElementsLi = subDoc.select(".list-dot.list-dot-paddingleft");
                if (subElementsLi.size() < 1 && honorNameList.contains(subMenuList.get(index)) || scientificNameList.contains(subMenuList.get(index))) {
                    // 荣誉表彰table样式
                    Elements elements = subDoc.select("table");
                    List<Honor> list = new ArrayList<>();
                    for (int i = 0; i < elements.size(); i++) {
                        Elements thead = elements.get(i).select("thead tr th");
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("thead tr td");
                        }
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("tbody tr th");
                        }
                        if (thead.size() == 0) {
                            thead = elements.get(i).select("tbody tr td");
                        }
                        Map<String, Integer> tbodyMap = CasCrawlerService.getStringIntegerMap(thead);
                        Elements trElements = elements.get(i).select("tbody").select("tr");
                        if (trElements.size() <= 0)
                            trElements = elements.get(i).select("tr");
                        getTableSaveHonor(tbodyMap, trElements, list, userName, 1);
                    }

                    if (!map.containsKey("honorsData") && CollectionUtils.isNotEmpty(list))
                        map.put("honorsData", JSON.toJSONString(list));
                    else if (map.containsKey("honorsData")) {
                        List<Honor> list2 = JSON.parseArray(map.get("honorsData"), Honor.class);
                        list.addAll(list2);
                        map.put("honorsData", JSON.toJSONString(list));
                    }
                }
                if (StringUtils.isBlank(map.get("honorsData")) && subElementsLi.size() < 1 && honorNameList.contains(subMenuList.get(index)) || scientificNameList.contains(subMenuList.get(index))) {

                    // 荣誉表彰div样式
                    String text = subDoc.select("div").text();
                    if (StringUtils.containsAny(text, StringUtils.join(noNameList, ","))) {
                        for (int i = 0; i < noNameList.size(); i++) {
                            if (text.indexOf(noNameList.get(i)) > 0) {
                                text = text.substring(0, text.indexOf(noNameList.get(i)));
                            }
                        }
                    }
                    text = RegexUtils.replaceData(text, RegexUtils.ALL_ZHONG_REGEX, "");
                    text = RegexUtils.replaceData(text, userName, "");
                    List<Honor> list = new ArrayList<>();
                    if (text.indexOf("。") > 0) {
                        String[] texts = text.split("。");
                        subHonors(list, texts);
                    }
                    if (CollectionUtils.isEmpty(list) && text.indexOf(" ") > 0) {
                        String[] texts = text.split(" ");
                        subHonors(list, texts);
                    }


                    if (!map.containsKey("honorsData") && CollectionUtils.isNotEmpty(list))
                        map.put("honorsData", JSON.toJSONString(list));
                    else if (map.containsKey("honorsData")) {
                        List<Honor> list2 = JSON.parseArray(map.get("honorsData"), Honor.class);
                        list.addAll(list2);
                        map.put("honorsData", JSON.toJSONString(list));
                    }
                }
                List<String> subMenuList2 = new ArrayList<>();
                for (Element element : subElementsLi) {
                    String text = element.select("div").text().replaceAll("&", "&amp;");
                    subMenuList2.add(text);
                }
                for (int j = 0; j < subMenuList2.size(); j++) {
                    String liStr = "";
                    if (j == subMenuList2.size() - 1) {
                        liStr = subMenuContent.substring(subMenuContent.indexOf(subMenuList2.get(j)) + subMenuList2.get(j).length(), subMenuContent.length());
                    } else {
                        String thisStr = subMenuList2.get(j);
                        String nextStr = subMenuList2.get(j + 1);
                        if (StringUtils.isNotBlank(thisStr) && StringUtils.isNotBlank(nextStr)) {
                            Integer indexOf1 = subMenuContent.indexOf(thisStr) + thisStr.length();
                            Integer indexOf2 = subMenuContent.indexOf(nextStr);
                            liStr = subMenuContent.substring(indexOf1, indexOf2);
                        }
                    }
                    if (StringUtils.isNotBlank(liStr) && StringUtils.isNotBlank(subMenuList2.get(j)))
                        map.put(subMenuList2.get(j), liStr);
                }
            }
        } else {
//            String value = menuMap.get(key).toString();
            String obj = subMenuList.get(index);
            content = content.substring(content.indexOf(obj) + obj.length(), content.length());
            endFlag = content.substring(0, 10);
            subScreenData(content, endFlag, index, subMenuList, map, menuMap, key);
        }
    }

    private void subHonors(List<Honor> list, String[] texts) {
        for (int i = 0; i < texts.length; i++) {
            if (StringUtils.isNotBlank(texts[i])) {
                Honor honor = new Honor().builder().type(1).build();
                honor.setPrizeName(texts[i]);
                getPrizeLevel(honor, texts[i]);
                getAwardLevel(honor, texts[i]);
                list.add(honor);
            }
        }
    }

    /**
     * 目录处理
     *
     * @param map             保存院士数据的map
     * @param contentElements html内容
     * @param menuMap         目录标题map
     * @param key             目录标题编号
     * @param value           目录标题
     */
    private void handleMenu(Map<String, String> map, Elements contentElements, Map<String, Object> menuMap, String key, Object value, String name) {
        Map<String, String> splitMap = new HashMap();
        if (StringUtils.equalsAny(value.toString(), "研究内容")) {
            splitMap = handleScreenData(map, contentElements, menuMap, key, value);
        }
        if (StringUtils.equalsAny(value.toString(), "人物评价")) {
            splitMap = handleScreenData(map, contentElements, menuMap, key, value);
        }
        if (StringUtils.equalsAny(value.toString(), "出版图书", "出版物", "代表作品")) {
            splitMap = handleScreenData(map, contentElements, menuMap, key, value);
        }
        if (honorNameList.contains(value.toString()) || scientificNameList.contains(value.toString())
                || socialNameList.contains(value.toString()) || researchNameList.contains(value.toString())
                || resumeNameList.contains(value.toString())) {
            splitMap = handleScreenData(map, contentElements, menuMap, key, value);
        }
        if (StringUtils.equalsAny(value.toString(), "家庭情况")) {
            splitMap = handleScreenData(map, contentElements, menuMap, key, value);
        }

        // 递归截取多个value值情况，只保留当前value最后一次出现到menuMap当前value的下一个value之前内容
        if (MapUtils.isNotEmpty(splitMap) && splitMap.containsKey("content") && splitMap.containsKey("endFlag")) {
            if (!StringUtils.equals(value.toString(), "主要成就")) {
                screenData(splitMap.get("content"), splitMap.get("endFlag"), key, menuMap, map, name);
            }
        }
    }

    private Map<String, String> handleScreenData(Map<String, String> map, Elements contentElements, Map<String, Object> menuMap, String key, Object value) {
        // 截取的字符串
        String content = contentElements.toString().substring(contentElements.toString().indexOf(value.toString()) + value.toString().length(), contentElements.toString().length());
        // 结束标识
        String endFlag = content.substring(0, 10);
        Map<String, String> splitMap = new HashMap();
        splitMap.put("content", content);
        splitMap.put("endFlag", endFlag);
        return splitMap;

    }

    /**
     * 递归截取数据
     *
     * @param content 内容
     * @param endFlag 结束标志
     * @param key     目录标题编号
     * @param menuMap 目录标题map
     * @param map     保存院士数据的map
     */
    private void screenData(String content, String endFlag, String key, Map<String, Object> menuMap, Map<String, String> map, String name) {
        if (StringUtils.contains(endFlag, "</h2>")) {
            String tempKey = String.valueOf(Integer.parseInt(key) + 1);
            Object obj = menuMap.get(tempKey);
            if (!ObjectUtils.isEmpty(obj) && obj instanceof String) {
                String menuContent = content.substring(0, content.indexOf(obj.toString()));
                // 保存目录对应的内容
                setMenuData(key, menuMap, map, menuContent, name);
            } else if (!ObjectUtils.isEmpty(obj) && obj instanceof ArrayList) {
                List list = (List) obj;
                String manyLevelText = list.get(0).toString();
                String menuContent = content.substring(0, content.indexOf(manyLevelText));
                // 保存目录对应的内容
                setMenuData(key, menuMap, map, menuContent, name);
            }
            if (null == obj) {
                // 百度百科，html个人详情信息结束标识
                Integer index = content.indexOf("J-main-content-end-dom");
                if (index < 0)
                    index = content.indexOf("百度百科");
                if (index < 0)
                    index = content.indexOf("参考资料");
                if (index < 0)
                    index = content.indexOf("。");
                if (index < 0)
                    index = content.indexOf("词条图册");
                String menuContent = content.substring(0, index);
                // 保存目录对应的内容
                setMenuData(key, menuMap, map, menuContent, name);
            }
        } else {
            Object value = menuMap.get(key);
            if (!ObjectUtils.isEmpty(value) && value instanceof String) {
                content = content.substring(content.indexOf(value.toString()) + value.toString().length(), content.length());
                endFlag = content.substring(0, 10);
                // 递归截取数据
                screenData(content, endFlag, key, menuMap, map, name);
            } else if (!ObjectUtils.isEmpty(value) && value instanceof ArrayList) {
                List<String> valueList = (List) value;
                content = content.substring(content.indexOf(valueList.get(0)) + valueList.get(0).length(), content.length());
                endFlag = content.substring(0, 10);
                // 递归截取数据
                screenData(content, endFlag, key, menuMap, map, name);
            }
        }
    }

    /**
     * 保存目录对应的内容
     *
     * @param key         目录标题编号
     * @param menuMap     目录map
     * @param map         院士信息map
     * @param menuContent 目录标题对应的内容
     */
    private void setMenuData(String key, Map<String, Object> menuMap, Map<String, String> map, String menuContent, String userName) {
        Document doc = CrawlerCommonUtils.getDocumentByString(menuContent);
        Object tempObj = menuMap.get(key);
        if (!ObjectUtils.isEmpty(tempObj) && tempObj instanceof String) {
            // 社会任职 table
            Elements tbodyEle = doc.select("table tbody");
            Map<String, Integer> tbodyMap = new HashMap<>();
            List<Social> list = new ArrayList<>();
            for (int i = 0; i < tbodyEle.size(); i++) {
                Elements trElements = tbodyEle.get(i).select("tr");
                Elements thead = trElements.get(0).select("td");
                if (thead.size() < 1) {
                    thead = trElements.get(0).select("th");
                }
                tbodyMap = CasCrawlerService.getStringIntegerMap(thead);
                setSubMap(tbodyMap, trElements, list, userName);
            }
            if (CollectionUtils.isNotEmpty(list)) {
                //        if (StringUtils.equalsAny(tempObj.toString(), "社会任职", "社会职务", "担任职务", "主要经历", "教育及工作经历", "先后任职", "学术兼职")) {
                if (socialNameList.contains(tempObj.toString())) {
                    map.put("socialData", JSON.toJSONString(list));
                } else {
                    map.put(tempObj.toString(), JSON.toJSONString(list));
                }
                return;
            }

            if (socialNameList.contains(tempObj.toString())) {
                // 解析社会任职
                parseSocialData(map, tempObj, doc, userName);
                return;
            }

            if (resumeNameList.contains(tempObj.toString())) {
                parseHtmlResume(map, userName, doc);
                return;
            }

            // 一级目录成就与荣誉
            if (StringUtils.equalsAny(tempObj.toString(), "成就与荣誉")) {
                Elements elementsDiv = doc.select("div");
                List<Honor> scientificResultList = new ArrayList<>();
                List<Honor> honorsData = new ArrayList<>();
                for (Element elementDiv : elementsDiv) {
                    String divText = elementDiv.select("div").text();
                    if (divText.contains("年") && divText.contains("奖")) {
                        // scientificResult 科研成果
                        Honor honor = new Honor().builder().type(0).build();
                        String[] honors = divText.split("年");
                        if (honors.length > 1) {
                            honor.setHonorDate(honors[0] + "年");
                            String prizeName = honors[1];
                            prizeName = handeFuHao(prizeName);
                            prizeName = RegexUtils.replaceData(prizeName, RegexUtils.ALL_ZHONG_REGEX, "");
                            honor.setPrizeName(prizeName);
                            if (prizeName.contains("(") && prizeName.contains(")")) {
                                String completePerson = RegexUtils.getTextContent(prizeName, RegexUtils.ALL_KUA_REGEX_TWO);
                                honor.setCompletePerson(completePerson);
                            }
                        } else if (honors.length == 1) {
                            String prizeName = honors[1];
                            prizeName = handeFuHao(prizeName);
                            prizeName = RegexUtils.replaceData(prizeName, RegexUtils.ALL_ZHONG_REGEX, "");
                            honor.setPrizeName(prizeName);
                            if (prizeName.contains("(") && prizeName.contains(")")) {
                                String completePerson = RegexUtils.getTextContent(prizeName, RegexUtils.ALL_KUA_REGEX_TWO);
                                honor.setCompletePerson(completePerson);
                            }
                        }
                        scientificResultList.add(honor);
                    } else if (divText.contains("年")) {
                        // 荣誉表彰
                        Honor honor = new Honor().builder().type(1).build();
                        divText = RegexUtils.replaceData(divText, RegexUtils.ALL_ZHONG_REGEX, "");
                        divText = handeFuHao(divText);
                        honor.setPrizeName(divText);
                        honorsData.add(honor);
                    }
                }
                if (CollectionUtils.isNotEmpty(scientificResultList))
                    map.put("scientificResult", JSON.toJSONString(scientificResultList));

                if (CollectionUtils.isNotEmpty(honorsData))
                    map.put("honorsData", JSON.toJSONString(honorsData));
            }

            if (honorNameList.contains(tempObj.toString()) || scientificNameList.contains(tempObj.toString())) {

                List<String> imgAltList = getImgAltName(userName, doc);

                if (StringUtils.contains(doc.toString(), "学生获奖") && doc.toString().indexOf("学生获奖") > 0) {
                    String subStrDoc = doc.toString().substring(0, doc.toString().indexOf("学生获奖"));
                    doc = CrawlerCommonUtils.getDocumentByString(subStrDoc);
                }

                if (StringUtils.containsAny(doc.toString(), StringUtils.join(noNameList, ","))) {
                    for (int i = 0; i < noNameList.size(); i++) {
                        if (doc.toString().indexOf(noNameList.get(i)) > 0) {
                            String subStr = doc.toString().substring(0, doc.toString().indexOf(noNameList.get(i)));
                            doc = CrawlerCommonUtils.getDocumentByString(subStr);
                        }
                    }
                }

                Elements elementsDiv = doc.select("div");
                List<Honor> honorsData = new ArrayList<>();
                for (int i = 0; i < elementsDiv.size(); i++) {
                    Element elementDiv = elementsDiv.get(i);
                    String divText = elementDiv.select("div").text();
                    divText = divText.replaceAll(userName, "");
                    if (StringUtils.isBlank(divText)) {
                        continue;
                    }

                    for (int j = 0; j < imgAltList.size(); j++) {
                        divText = RegexUtils.replaceData(divText, imgAltList.get(j), "");
                        divText = divText.replaceAll(userName, "");
                    }

                    String dd = RegexUtils.getTextContent(divText, RegexUtils.ALL_KUA_REGEX_TWO);
                    if (dd.contains("张"))
                        divText = RegexUtils.replaceData(divText, RegexUtils.ALL_KUA_REGEX, "");
                    Honor honor = new Honor().builder().build();
                    if (honorNameList.contains(tempObj.toString())) {
                        honor.setType(1);
                    } else if (scientificNameList.contains(tempObj.toString())) {
                        honor.setType(0);
                    } else {
                        honor.setType(1);
                    }

                    divText = RegexUtils.replaceData(divText, RegexUtils.ALL_ZHONG_REGEX, "");
                    if (divText.indexOf("。") > 0) {
                        String[] divTexts = divText.split("。");
                        for (int j = 0; j < divTexts.length; j++) {
                            honor = new Honor().builder().build();
                            if (honorNameList.contains(tempObj.toString())) {
                                honor.setType(1);
                            } else if (scientificNameList.contains(tempObj.toString())) {
                                honor.setType(0);
                            } else {
                                honor.setType(1);
                            }
                            String text = divTexts[j];
                            setOneLevelMenuHonor(honorsData, text, honor);
                        }
                        if (CollectionUtils.isNotEmpty(honorsData)) {
                            continue;
                        }
                    }
                    setOneLevelMenuHonor(honorsData, divText, honor);
                }

                if (honorNameList.contains(tempObj.toString())) {
                    if (!map.containsKey("honorsData") && CollectionUtils.isNotEmpty(honorsData)) {
                        map.put("honorsData", JSON.toJSONString(honorsData));
                    } else if (map.containsKey("honorsData")) {
                        List<Honor> list2 = JSON.parseArray(map.get("honorsData"), Honor.class);
                        honorsData.addAll(list2);
                        map.put("honorsData", JSON.toJSONString(honorsData));
                    }
                } else if (scientificNameList.contains(tempObj.toString())) {
                    if (!map.containsKey("scientificResult") && CollectionUtils.isNotEmpty(honorsData)) {
                        map.put("scientificResult", JSON.toJSONString(honorsData));
                    } else if (map.containsKey("scientificResult")) {
                        List<Honor> list2 = JSON.parseArray(map.get("scientificResult"), Honor.class);
                        honorsData.addAll(list2);
                        map.put("scientificResult", JSON.toJSONString(honorsData));
                    }
                }
            }

            if (researchNameList.contains(tempObj.toString())) {
                String research = doc.select("div").text();
                research = RegexUtils.replaceData(research, RegexUtils.ALL_ZHONG_REGEX, "");
                if (research.length() > 256) {
                    Integer indexOf = research.indexOf("。");
                    if (null != indexOf && indexOf > 0) {
                        research = research.substring(0, indexOf);
                    } else {
                        research = research.replaceAll("，", ",");
                        indexOf = research.indexOf(",");
                        if (indexOf > 0)
                            research = research.substring(0, indexOf);
                    }
                    if (research.length() <= 256) {
                        research = research.replaceAll("研究方向", "");
                        map.put("research", handeFuHao(research));
                    }
                } else {
                    research = research.replaceAll("研究方向", "");
                    map.put("research", handeFuHao(research));
                }
            }


            // 社会任职div
            String divText = doc.select("div").text();
            // 去除[]
            divText = RegexUtils.replaceData(divText, RegexUtils.ALL_ZHONG_REGEX, "");
            if (StringUtils.isNotBlank(divText) && map.containsKey("中文名") && StringUtils.isNotBlank(map.get("中文名"))) {
                divText = divText.replaceAll(map.get("中文名"), "");
                map.put(tempObj.toString(), divText);
            }
        } else if (!ObjectUtils.isEmpty(tempObj) && tempObj instanceof List) {
            List list2 = (List) tempObj;
            String manyLevelText2 = list2.get(0).toString();
            // 如果子目录是社会任职（如：社会任职，包含：现任职务、曾任职务）下的，不用之后再解析
            if (socialNameList.contains(manyLevelText2)) {
//                System.out.println(doc.select("div"));

                List<Social> list = new ArrayList<>();
                // 解析社会任职
                parseSocialData(map, tempObj, doc, userName);
                return;
            }

            if (resumeNameList.contains(manyLevelText2)) {
                parseHtmlResume(map, userName, doc);
                return;
            }


            // 如果目录中包含子目录，把子目录的html放入map，之后再解析
            map.put(manyLevelText2, doc.toString());
        }
    }

    /**
     * 获取img标签的alt,放到List中返回
     *
     * @param name
     * @param doc
     * @return
     */
    private List<String> getImgAltName(String name, Document doc) {
        List<String> imgTextList = new ArrayList<>();
        Elements imgElements = doc.select("div").select("img");
        for (int i = 0; i < imgElements.size(); i++) {
            String imgAttrText = imgElements.get(i).attr("alt");
            imgAttrText = RegexUtils.replaceData(imgAttrText, name, "");
            if (StringUtils.isNotBlank(imgAttrText))
                imgTextList.add(imgAttrText);
        }
        return imgTextList;
    }

    private void setOneLevelMenuHonor(List<Honor> honorsData, String divText, Honor honor) {
        String prizeName = handeFuHao(divText);
        prizeName = prizeName.replaceAll("词条图册", "").replaceAll("更多图册", "");
        if (StringUtils.isNotBlank(prizeName)) {
            honor.setPrizeName(prizeName);
            getPrizeLevel(honor, prizeName);
            getAwardLevel(honor, prizeName);
            getCompletePerson(honor, prizeName);
            honorsData.add(honor);
        }
    }

    /**
     * 获取奖项中的完成人排名
     *
     * @param honor
     * @param prizeName
     */
    private void getCompletePerson(Honor honor, String prizeName) {
        if (prizeName.contains("(") && prizeName.contains(")")) {
            String completePerson = RegexUtils.getTextContent(prizeName, RegexUtils.ALL_KUA_REGEX_TWO);
            if (StringUtils.containsAny(completePerson, "完成者", "完成人", "排", "第", "唯一", "首位")) {
                honor.setType(0);
                honor.setCompletePerson(completePerson);
            }
        }
    }

    /**
     * 解析html中，"人物生平", "个人履历", "个人信息", "人物履历", "人物经历", "人物简历", "履历" 数据
     *
     * @param map
     * @param userName
     * @param doc
     */
    private void parseHtmlResume(Map<String, String> map, String userName, Document doc) {
        Elements divElements = doc.select("div");
        Elements spanElements = doc.select("div span");
        List<String> spanList = new ArrayList<>();
        for (int i = 0; i < spanElements.size(); i++) {
            String spanText = spanElements.get(i).text();
            if (StringUtils.isNotBlank(spanText)) {
                spanText = spanText.replaceAll(userName, "");
                spanList.add(spanText);
            }
        }
        List<String> resumeList = new ArrayList<>();
        for (Element s : divElements) {
            String text = s.text();
            text = text.replaceAll("主要学历", "")
                    .replaceAll("工作经历", "")
                    .replaceAll(userName + "教授", "")
                    .replaceAll(userName, "")
                    .replaceAll("相关照片", "")
                    .replaceAll("教育经历", "")
                    .replaceAll("其中", "");

            text = RegexUtils.replaceData(text, RegexUtils.ALL_ZHONG_REGEX, "");
//                    System.out.println(text);
            for (int j = 0; j < spanList.size(); j++) {
                text = RegexUtils.replaceData(text, spanList.get(j), "");
            }
            if (StringUtils.isNotBlank(text)) {

                text = text.replaceAll("“", "").replaceAll("”", "").replaceAll("，", ",")
                        .replaceAll("：", ":").replaceAll(":", "").replaceAll("（", "(")
                        .replaceAll("）", ")");
                text = text.replaceAll("\\(", "").replaceAll("\\)", "");
                resumeList.add(text);
            }
        }
        if (!map.containsKey("resumeData") && CollectionUtils.isNotEmpty(resumeList)) {
            map.put("resumeData", JSON.toJSONString(resumeList));
        } else if (map.containsKey("resumeData")) {
            List<String> list = JSON.parseArray(map.get("resumeData"), String.class);
            resumeList.addAll(list);
            map.put("resumeData", JSON.toJSONString(resumeList));
        }
    }

    /**
     * 解析社会任职
     *
     * @param map
     * @param tempObj
     * @param doc
     */
    private void parseSocialData(Map<String, String> map, Object tempObj, Document doc, String name) {
        if (StringUtils.containsAny(doc.toString(), StringUtils.join(noNameList, ","))) {
            for (int i = 0; i < noNameList.size(); i++) {
                if (doc.toString().indexOf(noNameList.get(i)) > 0) {
                    String subStr = doc.toString().substring(0, doc.toString().indexOf(noNameList.get(i)));
                    doc = CrawlerCommonUtils.getDocumentByString(subStr);
                }
            }
        }
        Elements divElements = doc.select("div");
        List<String> imgAltList = getImgAltName(name, doc);
//        String dateTmp = "";
        for (int s = 0; s < divElements.size(); s++) {
            List<Social> list = new ArrayList<>();
            Element element = divElements.get(s);
            Social social = new Social();
            String divText = element.text();
            divText = RegexUtils.replaceData(divText, RegexUtils.ALL_ZHONG_REGEX, "");
//            divText = handeFuHao(divText);
            divText = divText.replaceAll(name, "").replaceAll("现任职务", "").replaceAll("曾任职务", "");

            for (int i = 0; i < imgAltList.size(); i++) {
                divText = RegexUtils.replaceData(divText, imgAltList.get(i), "");
                divText = divText.replaceAll(name, "");
            }

            String dd = RegexUtils.getTextContent(divText, RegexUtils.ALL_KUA_REGEX_TWO);
            if (dd.contains("张"))
                divText = RegexUtils.replaceData(divText, RegexUtils.ALL_KUA_REGEX, "");
            if (divText.contains("国际期刊"))
                divText = RegexUtils.replaceData(divText, "国际期刊", "");

            String startDivText = "";
            String endDivText = "";
            if (StringUtils.isNotBlank(divText)) {
                if (divText.indexOf("；") > 0) {
                    String[] divs = divText.split("；");
                    for (int i = 0; i < divs.length; i++) {
                        social = new Social();
                        if (StringUtils.isNotBlank(divs[i])) {

                            social.setDuties(handeFuHao(divs[i]));
                            list.add(social);
                        }
                    }

                    if (!map.containsKey("socialData") && CollectionUtils.isNotEmpty(list)) {
                        map.put("socialData", JSON.toJSONString(list));
                        continue;
                    } else if (map.containsKey("socialData")) {
                        List<Social> socialList = JSON.parseArray(map.get("socialData"), Social.class);
                        socialList.addAll(list);
                        map.put("socialData", JSON.toJSONString(socialList));
                        continue;
                    }

                } else if (divText.indexOf("。") > 0) {
                    String[] divs = divText.split("。");
                    for (int i = 0; i < divs.length; i++) {
                        social = new Social();
                        social.setDuties(handeFuHao(divs[i]));
                        list.add(social);
                    }

                    if (!map.containsKey("socialData") && CollectionUtils.isNotEmpty(list)) {
                        map.put("socialData", JSON.toJSONString(list));
                        continue;
                    } else if (map.containsKey("socialData")) {
                        List<Social> socialList = JSON.parseArray(map.get("socialData"), Social.class);
                        socialList.addAll(list);
                        map.put("socialData", JSON.toJSONString(socialList));
                        continue;
                    }

                } else if (divText.indexOf(",") > 0) {
                    startDivText = divText.substring(0, divText.indexOf(","));
                    endDivText = divText.substring(divText.indexOf(",") + 1, divText.length());
                }

                if (StringUtils.isNotBlank(startDivText) && StringUtils.contains(startDivText, "年")) {
//                    dateTmp = startDivText;
                    try {
                        social.setTenure(DateUtils.handleDate(startDivText));
                        social.setDuties(endDivText);
                    } catch (Exception e) {
                        social.setDuties(divText);
                    }
                } else {
                    try {
                        if (StringUtils.isNotBlank(startDivText)) {
                            social.setTenure(DateUtils.handleDate(startDivText));
                        }
                        social.setDuties(divText);
                    } catch (Exception e) {
                        social.setDuties(divText);
                    }
                }
                list.add(social);
                if (!map.containsKey("socialData") && CollectionUtils.isNotEmpty(list)) {
                    map.put("socialData", JSON.toJSONString(list));
                } else if (map.containsKey("socialData")) {
                    List<Social> socialList = JSON.parseArray(map.get("socialData"), Social.class);
                    socialList.addAll(list);
                    map.put("socialData", JSON.toJSONString(socialList));
                }
//
            }
        }


    }

    /**
     * 符号处理
     *
     * @param text
     * @return
     */
    public String handeFuHao(String text) {
        return text.replaceAll("“", "").replaceAll("”", "").replaceAll("，", ",")
                .replaceAll("：", ":").replaceAll(":", "").replaceAll("。", "").replaceAll("（", "(")
                .replaceAll("）", ")");
    }

    /**
     * 获取奖项等级，国家级、省级、市级
     *
     * @param honor
     * @param prizeName
     */
    public void getPrizeLevel(Honor honor, String prizeName) {
        if (StringUtils.containsAny(prizeName, "国家", "中国")) {
            honor.setPrizeLevel(0);
        } else if (StringUtils.contains(prizeName, "省")) {
            honor.setPrizeLevel(1);
        } else if (StringUtils.contains(prizeName, "市")) {
            honor.setPrizeLevel(2);
        }
    }

    /**
     * 奖项层次 0：特等奖，1：一等级，2：二等奖，3：三等奖
     *
     * @param honor
     * @param prizeName
     */
    public void getAwardLevel(Honor honor, String prizeName) {
        if (StringUtils.contains(prizeName, "特等奖")) {
            honor.setType(0);
            honor.setAwardLevel(0);
        } else if (StringUtils.contains(prizeName, "一等奖")) {
            honor.setType(0);
            honor.setAwardLevel(1);
        } else if (StringUtils.contains(prizeName, "二等奖")) {
            honor.setType(0);
            honor.setAwardLevel(2);
        } else if (StringUtils.contains(prizeName, "三等奖")) {
            honor.setType(0);
            honor.setAwardLevel(3);
        }
    }

    private Document getBaiDuDocument(PersonInfo personInfo, Integer type) throws InterruptedException, IOException {
        Document doc = null;
        // TODO 测试的本地html
//        doc = CrawlerCommonUtils.getDocumentHtml("/htmlTest/cj-长江学者/222.html");
//        if (doc != null)
//            return doc;
//        Document doc = CrawlerCommonUtils.getDocumentHtml("/htmlTest/baidu-常进.html");
//        Document doc = CrawlerCommonUtils.getDocumentHtml("/htmlTest/baidu-钟南山.html");
//        Document doc = CrawlerCommonUtils.getDocumentHtml("/htmlTest/baidu-余永富.html");

        // 百度百科直接根据人名进行查询
//        Document doc = CrawlerCommonUtils.getDocument(crawlerPath3 + userName );
////        Document doc = CrawlerCommonUtils.getDocument(crawlerPath + userName + "%20院士");

        String major = personInfo.getMajor();
        // 随机暂停时间，避免百度禁用IP
        Thread.sleep(CommonUtils.randomRange(500, 1500));
        String userName = personInfo.getName();
        String workCompany = personInfo.getWorkCompany();

        // 获取百度百科人名搜索结果
        String namePath = null;
        if (type == 0) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + "院士");
        } else if (type == 1) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + workCompany + major);
        } else if (type == 4) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + workCompany);
        } else if (StringUtils.isNotBlank(workCompany)) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, workCompany);
        }  else if (type == 17) {
            String relatedLinks = personInfo.getRelatedLinks();
            if (StringUtils.isNotBlank(relatedLinks)) {
                List array = JSON.parseArray(relatedLinks);
                if (CollectionUtils.isNotEmpty(array)) {
                    namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + workCompany);
                }

                for (int i = 0; i < array.size(); i++) {
                    JSONObject jsonObject = (JSONObject) array.get(i);
                    // "relatedLinksName":"personInfoPath",
                    if (jsonObject.containsKey("relatedLinksName") && StringUtils.equals(jsonObject.getString("relatedLinksName"), "personInfoPath")) {
                        namePath = jsonObject.getString("relatedLinksUrl");
                        doc = CrawlerCommonUtils.getDocument(namePath);
                        return doc;
                    } else {
                        namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + workCompany);
                    }
                }
            }
        }else {
            return null;
        }
        // 条件：姓名+工作单位+专业，查询百度百科，获取查询结果列表doc,
        doc = getBaiduBaiKeList(namePath, userName, workCompany, major, type);

        // 条件：姓名+工作单位，重新查询百度百科，获取查询结果列表doc
        if (StringUtils.isNotBlank(workCompany)) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + workCompany);
            doc = getBaiduBaiKeListReset(namePath, doc, personInfo, type);
        }
        // 条件：姓名+专业，重新查询百度百科，获取查询结果列表doc
        if (StringUtils.isNotBlank(major)) {
            namePath = RegexUtils.replaceData(crawlerPath2, RegexUtils.ALL_REGEX, userName + major);
            doc = getBaiduBaiKeListReset(namePath, doc, personInfo, type);
        }

        if (null == doc) {
            return doc;
        }

        if (!StringUtils.containsAny(doc.toString(), "中国科学院", "中国工程院") && type == 0) {
            doc = CrawlerCommonUtils.getDocument(crawlerPath + userName);
        }

        return doc;
    }

    /**
     * 重新查询百度百科，获取查询结果列表doc
     *
     * @param doc
     * @param personInfo
     * @param type
     * @return
     * @throws InterruptedException
     */
    private Document getBaiduBaiKeListReset(String namePath, Document doc, PersonInfo personInfo, Integer type) throws InterruptedException {

        try {
            Thread.sleep(CommonUtils.randomRange(2000, 5000));
        } catch (InterruptedException e) {
        }
        String userName = personInfo.getName();
        String workCompany = personInfo.getWorkCompany();
        String major = personInfo.getMajor();
        if (null != doc) {
            String lemmaSummaryDivs = "";
            Elements contentElements = doc.select("div.main-content.J-content");
            if (null != contentElements && contentElements.size() == 0) {
                Elements contentElements2 = doc.select(".main-content.J-content");
                try {
                    lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").get(0).text();
                } catch (Exception e) {
                    lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").text();
                }
            } else {
                Elements contentElements2 = doc.select(".main-content.J-content");
                try {
                    lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").get(0).text();
                } catch (Exception e) {
                    lemmaSummaryDivs = contentElements2.get(0).select(".lemma-summary").select("div").text();
                }
            }

            // 个人简介
            if (StringUtils.isBlank(lemmaSummaryDivs)) {
                doc = getBaiduBaiKeList(namePath, userName, workCompany, major, type);
                return doc;
            }

            // 个人简介里不包含姓名的，说明页面错误。
            if (!StringUtils.contains(lemmaSummaryDivs, userName) && !StringUtils.contains(doc.toString(), userName + "的概述图")) {
                doc = getBaiduBaiKeList(namePath, userName, workCompany, major, type);
                return doc;
            }
        } else {
            doc = getBaiduBaiKeList(namePath, userName, workCompany, major, type);
        }
        return doc;
    }

    /**
     * 查询百度百科，获取查询结果列表doc
     *
     * @param path        路径
     * @param userName    姓名
     * @param workCompany 工作单位
     * @param major       专业
     * @param type        0：院士信息，1：长江学者，2：杰出青年，3：百人计划
     * @return
     * @throws InterruptedException
     */
    private Document getBaiduBaiKeList(String path, String userName, String workCompany, String major, Integer type) throws InterruptedException {

        Document doc = CrawlerCommonUtils.getDocument(path);
        // 解析html,包含院士的URL
        Element body_wrapperElement = doc.getElementById("body_wrapper");
        Elements baiduSearchResult = body_wrapperElement.select(".searchResult");
        Elements baiduSearchList = baiduSearchResult.select(".search-list");
        if (null != baiduSearchList) {
            if (baiduSearchList.size() <= 0)
                return null;
            for (Element element : baiduSearchList) {
                Elements ddElements = element.select("dd");
                for (Element ddElement : ddElements) {
                    Elements aElements = ddElement.select("a");
                    String pStr = ddElement.select("p").text();
                    for (int i = 0; i < aElements.size(); i++) {
                        Element aElement = aElements.get(i);

                        String searchRefh = aElement.attr("href");
                        String searchText = aElement.text();
                        if (StringUtils.containsAny(searchText, "中国科学院", "中国工程院") || StringUtils.containsAny(pStr, "中国科学院", "中国工程院")) {
                            // 随机暂停时间，避免百度禁用IP
                            doc = getBaiduBaiKeTwoLevel(userName, doc, searchRefh, type);
                            return doc;
                        } else if (StringUtils.contains(ddElement.toString(), userName) && StringUtils.contains(ddElement.toString(), workCompany) && StringUtils.containsAny(ddElement.toString(), "特聘教授", "讲座教授")) {
                            // 列表及列表描述，包含：姓名、推荐单位、特聘教授或讲座教授，为长江学者
                            doc = getBaiduBaiKeTwoLevel(userName, doc, searchRefh, type);
                            return doc;
                        } else if (StringUtils.contains(ddElement.toString(), userName) && StringUtils.contains(ddElement.toString(), workCompany)) {
                            // 列表及列表描述，只包含：姓名、推荐单位，为长江学者
                            doc = getBaiduBaiKeTwoLevel(userName, doc, searchRefh, type);
                            return doc;
                        } else if (StringUtils.contains(ddElement.toString(), userName) && StringUtils.contains(ddElement.toString(), major)) {
                            // 列表及列表描述，只包含：姓名、专业，为长江学者
                            doc = getBaiduBaiKeTwoLevel(userName, doc, searchRefh, type);
                            return doc;
                        } else if (StringUtils.contains(ddElement.toString(), userName)) {
                            // 列表及列表描述，只包含：姓名，为长江学者
                            doc = getBaiduBaiKeTwoLevel(userName, doc, searchRefh, type);
                            return doc;
                        }
                    }
                }
            }
        }
        return null;
    }

    /**
     * 进入百度百科列表
     *
     * @param userName
     * @param doc
     * @param searchRefh
     * @return
     * @throws InterruptedException
     */
    private Document getBaiduBaiKeTwoLevel(String userName, Document doc, String searchRefh, Integer type) throws InterruptedException {
        // 随机暂停时间，避免百度禁用IP
        Thread.sleep(CommonUtils.randomRange(1000, 2500));
        if (!StringUtils.contains(searchRefh, "baike.baidu.com")) {
            try {
                if (type == 0) {
                    doc = CrawlerCommonUtils.getDocument(BAIKE_Path + searchRefh);
                } else if (type == 1) {
                    doc = CrawlerCommonUtils.getDocument(BAIKE_Path + searchRefh);
                } else {
                    log.error("百度百科列表url未包含：baike.baidu.com，type=" + type + "类型未定义访问方式。");
                    throw new InterruptedException("百度百科列表url未包含：baike.baidu.com，type=" + type + "类型未定义访问方式。");
                }
            } catch (Exception e) {
                log.error("BaiduBaiKeCrawlerService - getBaiDuDocument - Exception: {}", e);
            }
        } else {
            doc = CrawlerCommonUtils.getDocument(searchRefh);
        }
        return doc;
    }


    /**
     * 从个人简历中获取属性
     *
     * @param map
     * @param lemmaSummaryDivs
     */
    public void getLemmaSummaryDivsProperty(Map<String, String> map, String lemmaSummaryDivs) {
        // 获取个人简介中的性别
        if (!map.containsKey("性别") && StringUtils.contains(lemmaSummaryDivs, ",男,")) {
            map.put("性别", "男");
        } else if (!map.containsKey("性别") && StringUtils.contains(lemmaSummaryDivs, ",女,")) {
            map.put("性别", "女");
        }
        if (!map.containsKey("政党") && StringUtils.containsAny(lemmaSummaryDivs, "加入中国共产党", "中国共产党党员", "中共党员")) {
            map.put("政党", "中国共产党");
        }
        if (!map.containsKey("职称")) {
            if (StringUtils.contains(lemmaSummaryDivs, "教授") && StringUtils.contains(lemmaSummaryDivs, "副教授")) {
                map.put("职称", "教授");
            } else if (StringUtils.contains(lemmaSummaryDivs, "副教授")) {
                map.put("职称", "副教授");
            } else {
                map.put("职称", "教授");
            }
        }
        if (StringUtils.contains(lemmaSummaryDivs, "长江学者")) {
            map.put("长江学者", "长江学者");
        }
    }

    /**
     * 获取学位
     *
     * @param map
     * @param lemmaSummaryDivs
     */
    public String setProperty(Map<String, String> map, String lemmaSummaryDivs, String variable) {
        String degree = "";
        if (!map.containsKey(variable) && StringUtils.contains(lemmaSummaryDivs, variable)) {
            degree = RegexUtils.getTextContent(lemmaSummaryDivs, RegexUtils.DEGREE_REGEX);
            degree = degree.replaceAll("得", "");
            if (StringUtils.isNotBlank(degree) && degree.length() <= 10) {
                String degree2 = RegexUtils.getTextContent(degree, RegexUtils.DEGREE_REGEX_TWO);
                if (StringUtils.isNotBlank(degree2))
                    map.put(variable, degree2 + "士");
                else
                    map.put(variable, degree);
            }
        }
        return degree;
    }

    public void handlerMap(Map<String, String> map) {
        if (map.containsKey("研究方向")) {
            String temp = map.get("研究方向");
            map.put("研究内容", temp);
        }
        if (map.containsKey("籍贯")) {
            String temp = map.get("籍贯");
            map.put("出生地", temp);
        } else if (map.containsKey("原籍")) {
            String temp = map.get("原籍");
            map.put("出生地", temp);
        }

        if (map.containsKey("出版物")) {
            String temp = map.get("出版物");
            map.put("代表作品", map.get("代表作品") + "；" + temp);
        } else if (map.containsKey("出版图书")) {
            String temp = map.get("出版图书");
            map.put("代表作品", map.get("代表作品") + "；" + temp);
        }
        if (map.containsKey("学位/学历")) {
            String temp = map.get("学位/学历");
            map.put("学位", temp);
        } else if (map.containsKey("学历")) {
            String temp = map.get("学历");
            map.put("学位", temp);
        }
        if (map.containsKey("人物生平")) {
            String temp = map.get("人物生平");
            map.put("人物经历", temp);
        } else if (map.containsKey("个人履历")) {
            String temp = map.get("个人履历");
            map.put("人物经历", temp);
        } else if (map.containsKey("个人信息")) {
            String temp = map.get("个人信息");
            map.put("人物经历", temp);
        } else if (map.containsKey("人物履历")) {
            String temp = map.get("人物履历");
            map.put("人物经历", temp);
        } else if (map.containsKey("人物简历")) {
            String temp = map.get("人物简历");
            map.put("人物经历", temp);

        } else if (map.containsKey("履历")) {
            String temp = map.get("履历");
            map.put("人物经历", temp);
        }

        if (map.containsKey("主要成就")) {
            String temp = map.get("主要成就");
            map.put("成就", temp);
        } else if (map.containsKey("突出成就")) {
            String temp = map.get("突出成就");
            map.put("成就", temp);
        }
        if (map.containsKey("政治面貌")) {
            String temp = map.get("政治面貌");
            map.put("政党", temp);
        }
        if (map.containsKey("获奖记录")) {
            String temp = map.get("获奖记录");
            map.put("荣誉", temp);
        } else if (map.containsKey("荣誉表彰")) {
            String temp = map.get("荣誉表彰");
            map.put("荣誉", temp);
        } else if (map.containsKey("表彰")) {
            String temp = map.get("表彰");
            map.put("荣誉", temp);
        } else if (map.containsKey("所获荣誉")) {
            String temp = map.get("所获荣誉");
            map.put("荣誉", temp);
        }

        if (map.containsKey("就读院校")) {
            String temp = map.get("就读院校");
            map.put("毕业院校", temp);
        }


    }

}
